package com.android.lovely.room.role

import androidx.room.TypeConverter
import com.kotlin.extensions.json.JsonExt.fromJsonByType
import com.kotlin.extensions.json.JsonExt.toJsonByType

class StringConverter {
    @TypeConverter
    fun revert(content: String): MutableList<String> {
        return content.fromJsonByType<MutableList<String>>() ?: mutableListOf()
    }

    @TypeConverter
    fun convert(value: List<String>): String {
        return value.toJsonByType()
    }
}

class CreateConverter {
    @TypeConverter
    fun revert(content: String): MutableList<NewCard> {
        return content.fromJsonByType<MutableList<NewCard>>() ?: mutableListOf()
    }

    @TypeConverter
    fun convert(value: List<NewCard>): String {
        return value.toJsonByType()
    }
}